import {Service} from "adajs";
import User from "./../../lib/user";

class MenuService extends Service {
	defaultData() {
		return {
			menu: User.getUserFooter(),
			link: ""
		};
	}

	onupdate(current, data) {
		if (data.link) {
			current.menu.forEach(item => {
				if (item.link === data.link) {
					item.active = true;
				} else {
					item.active = false;
				}
			});
		}
	}
}

export default MenuService;